<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<style>
		.icon-filter{
			background:url('<%=path%>/images/filter.png') no-repeat center center;
		}
	</style>
<link rel="stylesheet" type="text/css"
	href="../js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../js/themes/icon.css">
<script type="text/javascript" src="../js/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../js/jquery.easyui.min.js"
	charset="utf-8"></script>
<script type="text/javascript" src="../js/locale/easyui-lang-zh_CN.js"
	charset="utf-8"></script>
	<script type="text/javascript" src="<%=path%>/js/datagrid-filter.js"></script>
<script type="text/javascript">
var das ="";
	$(function(){

	 	var sizes =new Array();
	 	var merges = [{
            index:0,
            rowspan:1
			          }];
		 $.ajax({
			  
	           type: "GET",
	           url:'<%=path%>/main/get/cb',
	          
			   data : {
				         "cropid":<%=session.getAttribute("cropid")%>,
					},
						async : false,
						success : function(data) {
							var data = eval('(' + data + ')');
							das=data.data.rows;
							sizes=data.data.sizes;
						
							for(var i=0;i<sizes.length;i++){
								merges.push(sizes[i]);
								
							}
						   }
		
					}); 
		 
		 
	 	 var dg = $('#tt').datagrid({
				filterBtnIconCls:'icon-filter',
				pagination : true,  
				onLoadSuccess:function(){
		 				
		 				 var merge = merges;
		 				  console.log(merge+"###")
							for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'cash',
									rowspan:merges[i].size,
									
								});
							 }
							for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'shuaka',
									rowspan:merges[i].size,
									
								});
							 }
							for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'zhipiao',
									rowspan:merges[i].size,
									
								});
							 }for(var i=1; i<merges.length; i++)
							 {
									
									$('#tt').datagrid('mergeCells',{
										
										index:merge[i].index,
										field:'dianhui',
										rowspan:merges[i].size,
										
									});
								 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'qiankuan',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'huaka',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'yajintrans',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'sitea',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'siteb',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'fuka',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'otherpay',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'otherrecive',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'yfcrop',
									rowspan:merges[i].size,
									
								});
							 }
							 for(var i=1; i<merges.length; i++)
							 {
								
								$('#tt').datagrid('mergeCells',{
									
									index:merge[i].index,
									field:'yscrop',
									rowspan:merges[i].size,
									
								});
							 }
						} 
			});
	 	 
		    var p = $('#tt').datagrid('getPager');  
		    $(p).pagination({  
		        pageSize: 10,//每页显示的记录条数，默认为10  
		        pageList: [10,15,20,25],//可以设置每页记录条数的列表  
		        beforePageText: '第',//页数文本框前显示的汉字  
		        afterPageText: '页    共 {pages} 页',  
		        displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',  
		    });
	 	 
			dg.datagrid('enableFilter', [{
				field:'jfje',
				type:'text',
				
				op:['equal','notequal','less','greater']
			},{
				field:'sjje',
				type:'text',
				
				op:['equal','notequal','less','greater']
			}
			]);  

	});
	</script>
<script>

</script>
<script type="text/javascript">
    function create(){
 	 
 	  var rows=  $('#tt').datagrid('getChecked');
 	  var params="";
 	  
 	  $.each(rows, function(index, row){
 	
 		  params+=row.lsh+",";
 			});
 	  
 	     $.ajax({
 		           type: "POST",
 		           url:"<%=path%>/main/create/excel",
 				   data : {
 	   		       "cropid":<%=session.getAttribute("cropid")%>,
 				   "params":params,
 	   				 },
 					async : false,
 					success : function(data) {
 					console.log(data);
 					var data = eval('(' + data + ')');
 					var num = data.data.status;
 					console.log(num);
 					if (num == 0) {
 	                  $.messager.alert("","成功创建excle");
 	                     
 					 }
 					if (num == 1) {
 	 	                  $.messager.alert("","再试一次吧!");
 	 	                     
 	 					 }

 				}
 		}); 
    }
  

</script>
<style>
#d1 {
	text-align: center;
}

#d3 {
	width: 2000px;
	margin: 45px auto;
}
</style>
<title>Insert title here</title>
</head>
<body>
	<div id="d1">
		<h2>公司台账</h2>
	</div>
	<div id="d3">
	    <input type="button" id="excel" value="生成excel" onclick="create()">
		
		<table id="tt" data-options="
				singleSelect:true,
				data:das">
			<thead>
			<tr>
				<th data-options="field:'lsh',width:80">流水号</th>
				<th data-options="field:'date',width:100">日期</th>
				<th data-options="field:'shoushudoc',width:80,align:'right'">手术医师</th>	
				<th data-options="field:'peitai',width:80,align:'right'">配台医师</th>
				<th data-options="field:'feishoushu',width:80,align:'right'">非手术医师</th>
				<th data-options="field:'cusname',width:80,align:'right'">顾客姓名</th>
				<th data-options="field:'xczx',width:80,align:'right'">现场咨询</th>
				<th data-options="field:'webzx',width:80,align:'right'">网络咨询</th>
				<th data-options="field:'phonezx',width:80,align:'right'">电话咨询</th>
				<th data-options="field:'scb',width:80,align:'right'">市场部</th>
				<th data-options="field:'menzhen',width:80,align:'right'">门诊</th>
				<th data-options="field:'qita',width:80,align:'right'">其他</th>
				<th data-options="field:'membername',width:80,align:'right'">会员名称</th>
				<th data-options="field:'xfdl',width:80,align:'right'">消费大类</th>
				<th data-options="field:'xmfl',width:80,align:'right'">项目分类</th>
				<th data-options="field:'xfmx',width:80,align:'right'">消费明细</th>
				<th data-options="field:'jfje',width:80,align:'right'">应缴费金额</th>
				<th data-options="field:'sjje',width:80,align:'right'">实际缴费金额</th>
				<th data-options="field:'zhekopulv',width:80,align:'right'">折扣率</th>
				<th data-options="field:'youhuijine',width:80,align:'right'">优惠金额</th>
				<th data-options="field:'cash',width:80,align:'right'">现金</th>
				<th data-options="field:'shuaka',width:80,align:'right'">刷卡</th>
				<th data-options="field:'zhipiao',width:80,align:'right'">支票</th>
				<th data-options="field:'dianhui',width:80,align:'right'">电汇</th>
				<th data-options="field:'qiankuan',width:80,align:'right'">欠款</th>
				<th data-options="field:'huaka',width:80,align:'right'">划卡</th>
				<th data-options="field:'yajintrans',width:80,align:'right'">押金转入</th>
				<th data-options="field:'sitea',width:80,align:'right'">网站a</th>
				<th data-options="field:'siteb',width:80,align:'right'">网站b</th>
				<th data-options="field:'fuka',width:80,align:'right'">福卡</th>
				<th data-options="field:'beiyong',width:80,align:'right'">服务项目</th>
				<th data-options="field:'otherpay',width:80,align:'right'">应付款</th>
				<th data-options="field:'yfcrop',width:80,align:'right'">应付公司</th>
				<th data-options="field:'otherrecive',width:80,align:'right'">其他应收</th>
				<th data-options="field:'yscrop',width:80,align:'right'">应收公司</th>
				<th data-options="field:'yuyuedate',width:80,align:'right'">预约金时间</th>
				<th data-options="field:'bankadate',width:80,align:'right'">办卡时间</th>
				<th data-options="field:'fapiaohao',width:80,align:'right'">发票号</th>
				<th data-options="field:'beizhu',width:80,align:'right'">备注</th>
				<th data-options="field:'chukudan',width:80,align:'right'">出库单</th>
				<th data-options="field:'shoukuanren',width:80,align:'right'">收款人</th>
							
			</tr>
		</thead>		
				
		</table>
		
	</div>


</body>
</html>